package com.atguigu.s_callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<String>{
    @Override
    public String call() throws Exception {
        System.out.println(Thread.currentThread().getName()+"...come in");
        return "hello futureTask...";
    }
}

public class test{
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask = new FutureTask<String>(new MyThread());
        new Thread(futureTask, "a").start();
        new Thread(futureTask, "b").start();
        System.out.println(futureTask.get()); // 获取返回结果
    }
}
